package com.lottery.game.core.model.dto.game;

import com.lottery.game.common.BaseObject;

import java.util.Date;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel(value = "当前期次结果Model",description = "当前期次结果Model")
public class CurrentGameIssue extends BaseObject {

	@ApiModelProperty(value = "期次编号" ,example="c956fe48c6174b6eb6aee1990f7b7298")
	private String id;

	@ApiModelProperty(value ="期次主题编号",example="20190413235248_2")
	private String issue;

	@ApiModelProperty(value ="期次编号",example="2413947")
	private String issueApi;

	//游戏状态 0正在进行，1已封盘 ，2已开奖，计算完  。-1开奖异常
	@ApiModelProperty(value ="游戏状态 0正在进行，1已封盘 ，2已开奖，计算完  。-1开奖异常",example="2")
	private String status;

	@ApiModelProperty(value ="创建时间",example="1555170757000")
	private Date createTime;

	@ApiModelProperty(value ="关闭时间",example="1555170890000")
	private Date closeTime;

	@ApiModelProperty(value ="开奖时间",example="1555170961000")
	private Date openTime;

	@ApiModelProperty(value ="开奖号码",example="3|3|2|8")
	private String note;

	@ApiModelProperty(value ="开奖结果",example="duizi|xiao|shuang|xiaoshuang|hongbo|")
	private String resultStr;

	//剩余游戏持续时间秒
	@ApiModelProperty(value ="剩余游戏持续时间秒",example="0")
	private int duration;

	//查询参数 当前时间
	@ApiModelProperty(value ="当前时间",example="1555293347382")
	private Date currentTime;

	public Date getCurrentTime() {
		return new Date();
	}

	public int getDuration() {
		if (openTime != null) {
			 if (openTime.getTime() > getCurrentTime().getTime()) {
			 	 return (int)(openTime.getTime() - getCurrentTime().getTime()) / 1000;
			 }
		}
		return 0;
	}
}
